package com.zhuang.chapter14.work04;

public class DataTest {

	public static void main(String[] args) {
		DataTest dataTest = new DataTest();
		dataTest.testStudent();
		System.out.println("===========================================");
		dataTest.testTeacher();
	}

	public void testStudent() {
		Teacher t1 = new Teacher(13, "小红");
		Teacher t2 = new Teacher(4, "小明");
		Teacher t3 = new Teacher(68, "小花");
		Teacher t4 = new Teacher(98, "小庄");
		Teacher t5 = new Teacher(24, "小康");
		TeacherData teacherData = new TeacherData();
		System.out.println("添加元素");
		teacherData.add(t1);
		teacherData.add(t2);
		teacherData.add(t3);
		teacherData.add(t4);
		teacherData.add(t5);
		System.out.println(teacherData.getArrayList());
		teacherData.remove(t1);
		System.out.println("\n删除元素");
		System.out.println(teacherData.getArrayList());
		System.out.println("\n更新元素");
		teacherData.update(2, new Teacher(66, "康小庄"));
		System.out.println(teacherData.getArrayList());
		System.out.println("\n查询元素");
		System.out.println(teacherData.query(3));
	}

	public void testTeacher() {
		Teacher t1 = new Teacher(1, "张三");
		Teacher t2 = new Teacher(2, "李四");
		Teacher t3 = new Teacher(3, "王五");
		Teacher t4 = new Teacher(4, "赵六");
		Teacher t5 = new Teacher(5, "田七");
		TeacherData teacherData = new TeacherData();
		System.out.println("添加元素");
		teacherData.add(t1);
		teacherData.add(t2);
		teacherData.add(t3);
		teacherData.add(t4);
		teacherData.add(t5);
		System.out.println(teacherData.getArrayList());
		teacherData.remove(t1);
		System.out.println("\n删除元素");
		System.out.println(teacherData.getArrayList());
		System.out.println("\n更新元素");
		teacherData.update(0, new Teacher(8, "新教师"));
		System.out.println(teacherData.getArrayList());
		System.out.println("\n查询元素");
		System.out.println(teacherData.query(1));
	}
}
